﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class UIKS03 : ViewBase
    {

        #region ==KSTKRS===========
        public static readonly DependencyProperty KSTKRSProperty = DependencyProperty.Register("KSTKRS",
            typeof(string), typeof(UIKS03),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKSTKRSChanged));
        public string KSTKRS
        {
            get
            {
                return (string)GetValue(KSTKRSProperty);
            }
            set
            {
                SetValue(KSTKRSProperty, value);
                OnKSTKRSChg(value);
            }
        }
        private static void OnKSTKRSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKS03;
            if (src != null)
            {
                src.KSTKRS = (string)e.NewValue;
            }
        }
        public virtual void OnKSTKRSChg(string value)
        { }
        #endregion
        #region ==KST===========
        public static readonly DependencyProperty KSTProperty = DependencyProperty.Register("KST",
            typeof(string), typeof(UIKS03),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKSTChanged));
        public string KST
        {
            get
            {
                return (string)GetValue(KSTProperty);
            }
            set
            {
                SetValue(KSTProperty, value);
                OnKSTChg(value);
            }
        }
        private static void OnKSTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKS03;
            if (src != null)
            {
                src.KST = (string)e.NewValue;
            }
        }
        public virtual void OnKSTChg(string value)
        { }
        #endregion
        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (!IsManage) 
            {
                VICC_WFEVENTS.SVWF.KS02(this.RUNID);
            }           
            base.ManageCommand(sender, e);
        }
        public void ResetSeq(object sender, RoutedEventArgs e)
        {
            if (!TMV.IsITX)
            {
                return;
            }
            VSDDAT.SD22.RESETSEQ("0022", KRS, "APFAUFTR", "1");       

        }

        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return; 
            base.Window_Loaded(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                KEY = "";
                KSTKRS = "";
                KST = "";

            }
            else
            {
                KEY = TMV.KSTKSTKRS + TMV.KSTKST;
                KSTKRS = TMV.KSTKSTKRS;
                KST = TMV.KSTKST;
            }
        }
        public override void SaveCommand(object sender, RoutedEventArgs e)
        {
            base.SaveCommand(sender, e);
        }

    }
        public partial class UIKS03
    {
        public VKSTSTELL TMV
        {
            get
            {
                return (VKSTSTELL)MV;
            }
        }
        #region ==FLOW===========
        public static readonly DependencyProperty FLOWProperty = DependencyProperty.Register("FLOW",
            typeof(string), typeof(UIKS03),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFLOWChanged));
        public string FLOW
        {
            get
            {
                return (string)GetValue(FLOWProperty);
            }
            set
            {
                SetValue(FLOWProperty, value);
                Locate("KEY", value);
            }
        }
        private static void OnFLOWChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKS03;
            if (src != null)
            {
                src.FLOW = (string)e.NewValue;
            }
        }
        #endregion  
    
    }
}
